import React from 'react';
import { Button } from 'antd';
import type { ButtonProps } from 'antd';

interface ButtonData {
  id: string;
  action: string;
}

interface AuthorizedButtonProps extends ButtonProps {
  buttonData: ButtonData[];
  action: string;
}

const AuthorizedButton: React.FC<AuthorizedButtonProps> = ({
  buttonData,
  action,
  ...buttonProps
}) => {
  const hasPermission = buttonData.some(button => button.action === action);
console.log(hasPermission);

  if (!hasPermission) {
    return null;
  }

  return <Button {...buttonProps} />;
};

export default AuthorizedButton;
